package com.happy3w.game.guess_num;

import java.text.MessageFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        NumGenerator numGenerator = new NumGenerator();
        NumMatcher numMatcher = new NumMatcher();
        GuessNum guessNum = new GuessNum(numGenerator, numMatcher);
        guessNum.initGuessNum();

        Scanner scanner = new Scanner(System.in);
        System.out.println("Please guess a number.");
        while(true) {
            int input = scanner.nextInt();
            GuessResult result = guessNum.guess(input);
            System.out.println(MessageFormat.format("Evaluation:{0}", result.getEvaluation()));

            if (result.getStatus() == GameStatus.PROCESSING) {
                System.out.println("Please try again:");
                continue;
            }

            if (result.getStatus() == GameStatus.SUCCESS) {
                System.out.println("You success.");
            } else if (result.getStatus() == GameStatus.FAILED) {
                System.out.println("Sorry, You are out.");
            }
            break;
        }
    }
}
